package com.qidianit.mes.pro.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qidianit.mes.pojo.Result;

import com.qidianit.mes.pojo.pro.ProductionOrder;
import com.qidianit.mes.pojo.pro.WorkflowProduct;
import com.qidianit.mes.pro.mapper.ProductionOrderMapper;
import com.qidianit.mes.pro.service.ProductionOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description:
 * @Author: wang fei long
 * @Date: 2025/9/17 0017 - 16:10
 */
@Service
public class ProductionOrderServiceImpl implements ProductionOrderService {

    @Autowired
    private ProductionOrderMapper productionOrderMapper ;


    @Override
    public Result<PageInfo<ProductionOrder>> selectList(int pageNum, int pageSize, ProductionOrder productionOrder, String materialName) {
        PageHelper.startPage(pageNum, pageSize);
        // 调用Mapper时，参数顺序与Mapper定义一致即可
        List<ProductionOrder> list = productionOrderMapper.selectList(productionOrder, materialName);
        return Result.success(new PageInfo<>(list));
    }

    @Override
    public Result<ProductionOrder> queryByCode(Long id) {
        return Result.success(productionOrderMapper.queryByCode(id));
    }

    @Override
    public Result<ProductionOrder> add(ProductionOrder productionOrder) {
        return productionOrderMapper.add(productionOrder)==1? Result.success(): Result.error("操作失败");
    }

    @Override
    public Result<ProductionOrder> updateById(ProductionOrder productionOrder) {
        return productionOrderMapper.updateById(productionOrder)==1? Result.success(): Result.error("操作失败");
    }

    @Override
    public Result deleteById(Long id) {
        return productionOrderMapper.deleteById(id)==1?Result.success(): Result.error("操作失败");
    }
}
